<template>
  <div class="welcome-page">
    <div class="welcome-content">
      <div class="welcome-header">
        <div class="welcome-icon">💬</div>
        <h1 class="welcome-title">欢迎使用聊天界面系统</h1>
        <p class="welcome-subtitle">现代化的客服聊天界面，支持响应式设计和多主题</p>
      </div>

      <div class="feature-grid">
        <div class="feature-card">
          <div class="feature-icon">📱</div>
          <h3 class="feature-title">响应式设计</h3>
          <p class="feature-description">完美适配桌面、平板和移动设备，提供一致的用户体验</p>
        </div>

        <div class="feature-card">
          <div class="feature-icon">🎨</div>
          <h3 class="feature-title">多主题支持</h3>
          <p class="feature-description">支持浅色、深色和高对比度主题，满足不同用户需求</p>
        </div>

        <div class="feature-card">
          <div class="feature-icon">⚡</div>
          <h3 class="feature-title">高性能</h3>
          <p class="feature-description">基于 Vue 3 和 TypeScript，提供流畅的交互体验</p>
        </div>

        <div class="feature-card">
          <div class="feature-icon">🔧</div>
          <h3 class="feature-title">可定制</h3>
          <p class="feature-description">丰富的配置选项和组件系统，轻松定制界面风格</p>
        </div>
      </div>

      <div class="action-section">
        <h2 class="action-title">开始体验</h2>
        <div class="action-buttons">
          <router-link to="/chat" class="btn btn-primary btn-lg">
            <i class="icon-chat"></i>
            <span>进入聊天界面</span>
          </router-link>
          <router-link to="/demo/layout" class="btn btn-secondary btn-lg">
            <i class="icon-layout"></i>
            <span>查看布局演示</span>
          </router-link>
        </div>
      </div>

      <div class="stats-section">
        <div class="stat-item">
          <div class="stat-number">{{ componentCount }}</div>
          <div class="stat-label">组件数量</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">{{ featureCount }}</div>
          <div class="stat-label">核心功能</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">{{ themeCount }}</div>
          <div class="stat-label">主题选择</div>
        </div>
        <div class="stat-item">
          <div class="stat-number">{{ deviceCount }}</div>
          <div class="stat-label">设备支持</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'

// 统计数据
const componentCount = ref(0)
const featureCount = ref(0)
const themeCount = ref(0)
const deviceCount = ref(0)

// 数字动画
const animateNumber = (target: any, endValue: number, duration: number = 1000) => {
  const startValue = 0
  const startTime = Date.now()
  
  const animate = () => {
    const elapsed = Date.now() - startTime
    const progress = Math.min(elapsed / duration, 1)
    
    // 使用缓动函数
    const easeOutQuart = 1 - Math.pow(1 - progress, 4)
    target.value = Math.floor(startValue + (endValue - startValue) * easeOutQuart)
    
    if (progress < 1) {
      requestAnimationFrame(animate)
    }
  }
  
  animate()
}

onMounted(() => {
  // 延迟启动动画
  setTimeout(() => {
    animateNumber(componentCount, 15, 1200)
    animateNumber(featureCount, 8, 1400)
    animateNumber(themeCount, 4, 1600)
    animateNumber(deviceCount, 3, 1800)
  }, 500)
})
</script>

<style scoped>
.welcome-page {
  min-height: 100%;
  background: linear-gradient(135deg, var(--color-background) 0%, var(--color-surface) 100%);
  padding: var(--spacing-xl);
  overflow-y: auto;
}

.welcome-content {
  max-width: 1200px;
  margin: 0 auto;
}

.welcome-header {
  text-align: center;
  margin-bottom: var(--spacing-3xl, 4rem);
}

.welcome-icon {
  font-size: 4rem;
  margin-bottom: var(--spacing-lg);
  animation: bounce 2s infinite;
}

.welcome-title {
  margin: 0 0 var(--spacing-lg) 0;
  font-size: 2.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  line-height: 1.2;
}

.welcome-subtitle {
  margin: 0;
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--spacing-xl);
  margin-bottom: var(--spacing-3xl, 4rem);
}

.feature-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-xl);
  padding: var(--spacing-xl);
  text-align: center;
  transition: all var(--transition-normal);
  box-shadow: var(--shadow-sm);
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary);
}

.feature-icon {
  font-size: 2.5rem;
  margin-bottom: var(--spacing-lg);
}

.feature-title {
  margin: 0 0 var(--spacing-md) 0;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.feature-description {
  margin: 0;
  color: var(--color-text-secondary);
  line-height: 1.6;
}

.action-section {
  text-align: center;
  margin-bottom: var(--spacing-3xl, 4rem);
}

.action-title {
  margin: 0 0 var(--spacing-xl) 0;
  font-size: 2rem;
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

.action-buttons {
  display: flex;
  gap: var(--spacing-lg);
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-xl);
  border: 1px solid transparent;
  border-radius: var(--border-radius-lg);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.btn-lg {
  padding: var(--spacing-lg) var(--spacing-2xl, 2rem);
  font-size: var(--font-size-lg);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
  border-color: var(--color-primary);
}

.btn-primary:hover {
  background: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background: var(--color-hover);
  border-color: var(--color-border-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stats-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--spacing-xl);
  padding: var(--spacing-xl);
  background: var(--color-surface);
  border-radius: var(--border-radius-xl);
  border: 1px solid var(--color-border);
}

.stat-item {
  text-align: center;
}

.stat-number {
  font-size: 2.5rem;
  font-weight: var(--font-weight-bold);
  color: var(--color-primary);
  margin-bottom: var(--spacing-sm);
}

.stat-label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* 图标样式 */
.icon-chat::before { content: '💬'; }
.icon-layout::before { content: '📐'; }

/* 动画 */
@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    transform: translate3d(0, -8px, 0);
  }
  70% {
    transform: translate3d(0, -4px, 0);
  }
  90% {
    transform: translate3d(0, -2px, 0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .welcome-page {
    padding: var(--spacing-lg);
  }
  
  .welcome-title {
    font-size: 2rem;
  }
  
  .feature-grid {
    grid-template-columns: 1fr;
  }
  
  .action-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .btn {
    width: 100%;
    max-width: 300px;
    justify-content: center;
  }
  
  .stats-section {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .stats-section {
    grid-template-columns: 1fr;
  }
}
</style>